use std::net::TcpStream;
use std::io::{BufRead, Read, Write};
use std::str;

fn main() {
    let mut stream=TcpStream::connect("localhost:3000").unwrap();
    stream.write("hwllo world".as_bytes()).unwrap();

    let mut buffer=[0;15];
    stream.read(&mut buffer).unwrap();
    //收到的字符需要转成utf8的字符串
    //这样打印的是整个 buffer，所以buffer初始化1024，会打印1024字节，
    //即使只收到 10字节的数据
    println!("from server recive:{:?}",str::from_utf8(&buffer).unwrap());
}
